using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Builder
{
  public partial class Slider : Form
  {
    public string Position;


    public Slider(Archetype Position, List<Archetype> Positions)
    {
      InitializeComponent();

      cmbxPosition.Items.Clear();
      foreach (Archetype at in Positions)
      {
        cmbxPosition.Items.Add(at);
      }
      cmbxPosition.DisplayMember = "DisplayName";
      cmbxPosition.ValueMember = "DisplayName";
      cmbxPosition.SelectedItem = Position;

      SetTrackBarLabel(trackBar1, lblTrackBar1);
      SetTrackBarLabel(trackBar2, lblTrackbar2);
    }

    private void trackBar2_Scroll(object sender, EventArgs e)
    {
      SetTrackBarLabel(sender as TrackBar, lblTrackbar2 as Label);
    }

    private void trackBar1_Scroll(object sender, EventArgs e)
    {
      SetTrackBarLabel(sender as TrackBar, lblTrackBar1 as Label);
    }


    private void SetTrackBarLabel(TrackBar trackBar, Label label)
    {
      label.Text = Math.Round(trackBar.Value / 6f, 2).ToString();
    }

    private void btnBuild_Click(object sender, EventArgs e)
    {
      Position = cmbxPosition.Text;
    }

    private void cmbxPosition_SelectedIndexChanged(object sender, EventArgs e)
    {
      lblHeightP.Text = String.Empty;
      Archetype at = cmbxPosition.SelectedItem as Archetype;
      lblHeightP.Text = String.Empty;
      lblHeightM.Text = String.Empty;
      lblWeightP.Text = String.Empty;
      lblWeightM.Text = String.Empty;
      foreach (String attr in at.HeightPlus)
      {
        if (lblHeightP.Text.Length==0)
        {
          lblHeightP.Text = attr + "/";
        }
        else
        {
          lblHeightP.Text += attr;
        }
      }
      foreach (String attr in at.HeightMinus)
      {
        if (lblHeightM.Text.Length == 0)
        {
          lblHeightM.Text = attr + "/";
        }
        else
        {
          lblHeightM.Text += attr;
        }
      }
      foreach (String attr in at.WeightPlus)
      {
        if (lblWeightP.Text.Length == 0)
        {
          lblWeightP.Text = attr + "/";
        }
        else
        {
          lblWeightP.Text += attr;
        }
      }
      foreach (String attr in at.WeightMinus)
      {
        if (lblWeightM.Text.Length == 0)
        {
          lblWeightM.Text = attr + "/";
        }
        else
        {
          lblWeightM.Text += attr;
        }
      }
    }

  }
}